import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn
} from 'typeorm';

import { User } from "../users/user.entity"

export enum Emotion {
  CELEBRATORY = 'celebratory',
  MEANINGFUL = 'meaningful',
  ELEGANT = 'elegant',
  FASHIONABLE = 'fashionable',
  UNIQUE = 'unique',
  OTHER = 'other',
}

export enum Gender {
  MALE = 'male',
  FEMALE = 'female',
  OTHER = 'other',
}

@Entity('publish')
export class Publish {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ nullable: true })
  user_id: number;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'user_id' })
  user: User;

  @Column({ length: 10 })
  role: string;

  @Column({ length: 255 })
  nickname: string;

  @Column('datetime')
  time: Date;

  @Column({ length: 255 })
  startLocation: string;

  @Column({ length: 255 })
  endLocation: string;

  @Column({ length: 20 })
  phone: string;

  @Column({ length: 255 })
  wechat: string;

  @Column({ length: 255 })
  email: string;

  @Column({ type: 'decimal', precision: 10, scale: 2 })
  price: number;

  @Column()
  peopleNumber: number;

  @Column({ length: 20 })
  carNumber: string;

  @Column()
  seat: number;

  @Column({ length: 255 })
  carModel: string;

  @Column({ length: 255 })
  via: string;

  @Column('text')
  remarks: string;

  @Column({ default: 0 })
  rocket: number;

  @Column({ default: 0 })
  collect: number;

  @Column({ default: 0 })
  report: number;

  @Column({ type: 'json', nullable: true })
  startProvince: Record<string, any>;

  @Column({ type: 'json', nullable: true })
  startCity: Record<string, any>;

  @Column({ type: 'json', nullable: true })
  startCounty: Record<string, any>;

  @Column({ type: 'json', nullable: true })
  endProvince: Record<string, any>;

  @Column({ type: 'json', nullable: true })
  endCity: Record<string, any>;

  @Column({ type: 'json', nullable: true })
  endCounty: Record<string, any>;

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}